package com.pubg.service.impl;

import com.pubg.dao.UserDao;
import com.pubg.dao.impl.UserDaoImpl;
import com.pubg.entity.User;
import com.pubg.service.UserService;
import com.pubg.util.SecurityUtil;

/**
 * 用户业务接口实现类
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public boolean insert(User user) {
        user.setPassword(SecurityUtil.md5hex3(user.getPassword()));
        return userDao.add(user)==1?true:false;
    }

    @Override
    public User login(String uname, String upwd) {
        upwd = SecurityUtil.md5hex3(upwd);
        return userDao.login(uname,upwd);
    }

    @Override
    public boolean findByName(String loginName) {
        return userDao.findByName(loginName)>0?true:false;
    }
}
